#ifndef _SHARP_GLOB_H
#define _SHARP_GLOB_H

#include "sharp-common.h"

/**
 * @file src/glob.c
 */

/**
 * Defines a sharp_glob for naming consistency with future regex libs, which is
 * just a string.
 */
typedef char * sharp_glob;

/**
 * Compiles a glob.
 * @param expr_string the pattern string to be compiled.
 *
 * Globs take no processing whatsoever, this is just for consistency with
 * future regex support. You may safely skip this step and just define a
 * pattern as a sharp_glob (which is just a string anyway). Note that
 * this glob implementation only handles * and ? characters as special
 * characters; ranges like [a-z] or multiple different expressions like
 * {foo,bar} are not implemented.
 */
sharp_glob sharp_glob_compile(char *expr_string);

/**
 * Check whether a glob pattern matches a string.
 * @param expr a pattern to match the target against
 * @param target the target string to be matched
 *
 * This function always matches the entire string, so "moo" won't match the
 * pattern "oo", but it would match "?oo".
 */
bool sharp_glob_match(sharp_glob expr, char *target);

/**
 * Finds a glob inside a string.
 * @param expr the pattern to match against
 * @param target the target string
 *
 * This function returns a pointer to the earliest match of the given glob
 * against the target string. Given a glob "m*" and a string "cows go moo",
 * a pointer to the "m" would be returned.
 */
char *sharp_glob_find(sharp_glob expr, char *target);

#endif /* _SHARP_GLOB_H */
